#include "ScriptManager.h"

template<> ScriptPlug::ScriptManager* Ogre::Singleton<ScriptPlug::ScriptManager>::ms_Singleton = 0;

namespace ScriptPlug
{
    ScriptManager::ScriptManager(void)
    {
    }

    ScriptManager::~ScriptManager(void)
    {
        scriptPlugins.clear();
    }

    void ScriptManager::Register(IScriptPlugin* scriptPlugin)
    {
        if(scriptPlugins.count(scriptPlugin->getName()) > 0) {
            scriptPlugins.erase(scriptPlugin->getName());
        }

        scriptPlugins[scriptPlugin->getName()] = scriptPlugin;
    }

    void ScriptManager::UnRegister(IScriptPlugin* scriptPlugin)
    {
        scriptPlugins.erase(scriptPlugin->getName());
    }

    IScriptPlugin* ScriptManager::GetScriptPlugin(Ogre::String name)
    {
        return scriptPlugins[name];
    }
}